//
//  XFDHomeTableViewCellOne.m
//  XFDHomeWorkPlatfrom_Example
//
//  Created by 朱国良 on 2017/11/2.
//  Copyright © 2017年 GL-ZHU. All rights reserved.
//

#import "XFDHomeTableViewCellOne.h"
#import "XFDNodeMenu.h"
#import <Masonry/Masonry.h>
#import <XFDCommon/UIImage+Extension.h>
#import <XFDCommon/UIColor+Extension.h>

@interface XFDHomeTableViewCellOne()

@property(nonatomic,copy)void(^clickBlock)(NSInteger index);
@end

@implementation XFDHomeTableViewCellOne

- (instancetype)init{
    self = [super init];
    if (self) {
        /// 左上角图片
        UIImageView *imageView = [[UIImageView alloc] init];
        imageView.image = [UIImage hb_imagePathWithName:@"work_equip" bundle:@"XFDHomeWorkPlatfrom" targetClass:[self class]];
        [self.contentView addSubview:imageView];
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(15);
            make.width.height.mas_equalTo(14);
            make.top.equalTo(self.contentView).offset(10);
        }];
        
        /// 头部标题
        UILabel *label = [[UILabel alloc] init];
        label.text = @"设备";
        label.textColor = [UIColor blackColor];
        [self.contentView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(imageView);
            make.left.equalTo(imageView.mas_right).offset(5);
            make.height.mas_equalTo(20);
            make.width.mas_equalTo(60);
        }];
        
        /// 底部菜单
        UIView *view = [[UIView alloc] init];
        view.backgroundColor = [UIColor HB_ColorWithHexString:@"#f6f6f6"];
        [self.contentView addSubview:view];
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self.contentView);
            make.top.equalTo(imageView.mas_bottom).offset(10);
        }];
        
        /// 无人机
        XFDNodeMenu *menu1 = [XFDNodeMenu nodeMenuLeftImageView:^(UIImageView *imageView) {
            
            imageView.image = [UIImage hb_imagePathWithName:@"work_equip_uav" bundle:@"XFDHomeWorkPlatfrom" targetClass:[self class]];
        } title:^(UILabel *label) {
            label.text = @"无人机";
        } content:^(UILabel *label) {
            label.text = @"0";
            self.label1 = label;
        } tapClick:^{
            self.clickBlock ? self.clickBlock(1) : nil;
        } small:NO];
        [view addSubview:menu1];
        [menu1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(view).offset(15);
            make.top.equalTo(view).offset(6);
            make.width.mas_equalTo(170);
            make.height.mas_equalTo(99);
        }];
        
        /// 无人机型号
        XFDNodeMenu *menu2 = [XFDNodeMenu nodeMenuLeftImageView:^(UIImageView *imageView) {
            imageView.image = [UIImage hb_imagePathWithName:@"work_equip_type" bundle:@"XFDHomeWorkPlatfrom" targetClass:[self class]];
        } title:^(UILabel *label) {
            label.text = @"无人机型号";
        } content:^(UILabel *label) {
            label.text = @"0";
            self.label2 = label;
        } tapClick:^{
            self.clickBlock ? self.clickBlock(2) : nil;
        } small:YES];
        [view addSubview:menu2];
        [menu2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(menu1.mas_right).offset(5);
            make.top.equalTo(menu1);
            make.right.equalTo(view).offset(-15);
            make.height.mas_equalTo(64);
        }];
        
        /// 追踪设备
        XFDNodeMenu *menu3 = [XFDNodeMenu nodeMenuLeftImageView:^(UIImageView *imageView) {
            
            imageView.image = [UIImage hb_imagePathWithName:@"work_equip_track" bundle:@"XFDHomeWorkPlatfrom" targetClass:[self class]];
        } title:^(UILabel *label) {
            label.text = @"追踪设备";
        } content:^(UILabel *label) {
            label.text = @"0";
            self.label3 = label;
        } tapClick:^{
            self.clickBlock ? self.clickBlock(3) : nil;
        } small:NO];
        [view addSubview:menu3];
        [menu3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.height.equalTo(menu1);
            make.top.equalTo(menu1.mas_bottom).offset(5);
        }];
        
        /// 荷载
        XFDNodeMenu *menu4 = [XFDNodeMenu nodeMenuLeftImageView:^(UIImageView *imageView) {
            
            imageView.image = [UIImage hb_imagePathWithName:@"work_equip_camera" bundle:@"XFDHomeWorkPlatfrom" targetClass:[self class]];
        } title:^(UILabel *label) {
            label.text = @"载荷";
        } content:^(UILabel *label) {
            label.text = @"0";
            self.label4 = label;
        } tapClick:^{
            self.clickBlock ? self.clickBlock(4) : nil;
        } small:YES];
        [view addSubview:menu4];
        [menu4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.height.equalTo(menu2);
            make.top.equalTo(menu2.mas_bottom).offset(5);
        }];
        
        /// 电池
        XFDNodeMenu *menu5 = [XFDNodeMenu nodeMenuLeftImageView:^(UIImageView *imageView) {
            imageView.image = [UIImage hb_imagePathWithName:@"work_equip_battery" bundle:@"XFDHomeWorkPlatfrom" targetClass:[self class]];
        } title:^(UILabel *label) {
            label.text = @"电池";
        } content:^(UILabel *label) {
            label.text = @"0";
            self.label5 = label;
        } tapClick:^{
            self.clickBlock ? self.clickBlock(5) : nil;
        } small:YES];
        [view addSubview:menu5];
        [menu5 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.height.equalTo(menu2);
            make.top.equalTo(menu4.mas_bottom).offset(5);
        }];
    }
    return self;
}
    
- (void)clickMenu:(void(^)(NSInteger index))clickBlock{
    self.clickBlock = clickBlock;
}
@end
